Sets the BulkData with a byte array.
public void SetBulkData(
byte[] byteArray
)
public:
void SetBulkData(
array<Byte>^ byteArray
)
byteArray
a byte array representing the BulkData
There are four ways to modify the BulkData:
using Leadtools.Dicom;
using Leadtools.Dicom.Common;
using Leadtools.Dicom.Common.Extensions;
using Leadtools;
using Leadtools.Dicom.Common.Linq.BasicDirectory;
using Leadtools.Dicom.Common.DataTypes;
using Leadtools.Codecs;
public static class SetBulkDataExample
{
public static bool MyLoadJsonBeforeElementCallback(LoadJsonBeforeElementData elementData)
{
// You can change the TransferSyntax here to any valid TransferSyntax
// Setting the TransferSyntax ElementValue to empty defaults the transfer syntax to Explicit VR Little Endian
//if (elementData.Tag == DicomTag.TransferSyntaxUID)
//{
// elementData.ElementValue = string.Empty;
//}
if (elementData.Encoding == ElementDataType.BulkData)
{
// If elementData.Encoding is ElementDataType.BulkData, then the BulkDataUri is returned in elementData.ElementValue
Console.WriteLine($"BulkDataUri: {elementData.ElementValue}");
// Set the bulk data: four ways to do it
//
string rawImagePath = Path.Combine(LEAD_VARS.ImagesDir, "image2.jpg");
string pngImagePath = Path.Combine(LEAD_VARS.ImagesDir, "PngImage.png");
// Method 1: Setting the [BulkData] property
using (FileStream fs = new FileStream(rawImagePath, FileMode.Open))
{
using (MemoryStream ms = new MemoryStream())
{
fs.CopyTo(ms);
elementData.BulkData = ms.ToArray();
}
}
// Method 2: Calling SetBulkData() with a byte array
using (FileStream fs = new FileStream(rawImagePath, FileMode.Open))
{
using (MemoryStream ms = new MemoryStream())
{
fs.CopyTo(ms);
elementData.SetBulkData(ms.ToArray());
}
}
// Method 3
// Set the bulk data using a RasterImage
using (RasterCodecs codecs = new RasterCodecs())
{
using (Leadtools.RasterImage image = codecs.Load(pngImagePath))
{
// The second argument is optional and specifies the QFactor
elementData.SetBulkData(image, 2);
}
}
// Method 4
// In this example(image2.dcm) it is raw jpeg data
// For uncompressed DICOM data, pass the raw uncompressedData
using (FileStream fs = new FileStream(rawImagePath, FileMode.Open))
{
elementData.SetBulkData(fs);
}
}
return true;
}
public static void MyLoadJson()
{
string dicomPath = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.dcm");
string jsonPath = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.json");
using (DicomDataSet dsJson = new DicomDataSet())
{
dsJson.Load(dicomPath, DicomDataSetLoadFlags.None);
dsJson.SaveJson(jsonPath, DicomDataSetSaveJsonFlags.IgnoreBinaryData);
}
using (DicomDataSet ds = new DicomDataSet())
{
ds.LoadJson(jsonPath, DicomDataSetLoadJsonFlags.None, MyLoadJsonBeforeElementCallback, null);
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
Leadtools.Dicom.Common.Extensions Namespace
[SetBulkData(byte[])]:../dco/Extensions-LoadBeforeElementData-SetBulkData(byte[]).md
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.